import org.bson.types.ObjectId;

import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;



public class Location {
	
	//ObjectId id;
	
	double latitude; // -90 to 90
	double longitude; // -180 to 180
	int region = 0;
	final int REGION_SIZE_X = 1; //long
	final int REGION_SIZE_Y = 1; //lat
	final int NUM_X = 100;
	final int NUM_Y = 100;
	int accuracy = 150;
	public Location(double latitude, double longitude, int accuracy)
	{
		this.latitude = latitude;
		this.longitude = longitude;
		this.accuracy = accuracy;
		Correct();
		//region = GetRegion();
		}
	public Location(double latitude, double longitude)
	{
		this.latitude = latitude;
		this.longitude = longitude;
		Correct();
		//region = GetRegion();
		System.out.println(region);

	}
	public Location(){}
	private void Correct()
	{
		if (latitude > 90) latitude -= 180;
		if (latitude < -90) latitude += 180;
		if (longitude > 180) longitude -= 360;
		if (longitude < -180) longitude += 360;
	}
	public int GetRegion()
	{
		int xCoord = (int)(((latitude+90)/(180/REGION_SIZE_X))*NUM_X);
		int yCoord = (int)(((longitude+180)/(360/REGION_SIZE_Y))*NUM_Y);
		
		return xCoord + (yCoord*NUM_X);
	}
}
